package com.itheima.linked;

import java.util.LinkedList;

public class LinkedListDemo01 {
    public static void main(String[] args) {
        LinkedList<String> linkedList = new LinkedList<>();
        linkedList.add("a");
        linkedList.add("b");
        linkedList.add("c");
        linkedList.add("d");
        System.out.println(linkedList);//[a, b, c, d]

        linkedList.addFirst("111");
        linkedList.addLast("222");
        System.out.println(linkedList);//[111, a, b, c, d, 222]

        System.out.println(linkedList.getFirst());//111
        System.out.println(linkedList.getLast());//222

        linkedList.removeFirst();
        System.out.println(linkedList);//[a, b, c, d, 222]
        linkedList.removeLast();
        System.out.println(linkedList);//[a, b, c, d]
    }
}
